package com.example.acceletracks;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.google.android.gms.maps.model.LatLng;

public class Route implements Serializable {

	private static final long serialVersionUID = 1L;
	private final List<LatLng> points;
	private final List<Float> speedPoints;

	public LatLng getStartPoint() {
		return points.get(0);
	}

	public LatLng getEndPoint() {
		return points.get(points.size() - 1);
	}
	
	public float getEndSpeedPoint()
	{
		return speedPoints.get(speedPoints.size() - 1);
	}
	

	public Route() {
        this.points = new LinkedList<LatLng>();
        this.speedPoints= new LinkedList<Float>();
	}
	
	public Route(List<LatLng> points) {
		this.points = new LinkedList<LatLng>(points);
		this.speedPoints= new LinkedList<Float>();
	}
	
	
	public Route(List<LatLng> points, List<Float> speedPoints) {
		this.points = new LinkedList<LatLng>(points);
		this.speedPoints= new LinkedList<Float>(speedPoints);
	}
	
	public void addPoint(final LatLng p, final float sp) {
		this.points.add(p);
		this.speedPoints.add(sp);

	}

	public void addPoints(final List<LatLng> points, List<Float> speedPoints) {
		this.points.addAll(points);
		this.speedPoints.addAll(speedPoints);
	}

	public int getLength() {
		return points.size();
	}
	public List<LatLng> getPoints() {
		return points;
	}
	public List<Float> getSpeedPoints() {
		return speedPoints;
	}

	@Override
	public String toString() {
		
		StringBuffer buffer = new StringBuffer();
		
		for(int i=0; i<points.size(); i++)
		{
			LatLng latlng=points.get(i);
			buffer.append(latlng.latitude + ",");
			buffer.append(latlng.longitude + ",");	
			buffer.append(speedPoints.get(i) + "\n");
		}
		return buffer.toString();
	}


}
